package com.example.sneakerappserver.service;

import com.example.sneakerappserver.pojo.Cart;
import com.example.sneakerappserver.repository.CartRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CartService implements ICartService{

    @Autowired
    CartRepository cartRepository;
    @Override
    public Long queryCartByUserId(Long userId) {
        return cartRepository.findCartByUserId(userId);
    }

    @Override
    public Cart createCartForUser(Long userId) {
        Cart cart = new Cart(userId);   // 创建一个新的购物车

        return cartRepository.save(cart);
    }

}
